package com.communal.web.form.cr;

import net.sf.ezmorph.bean.MorphDynaBean;
import net.sf.json.JSONObject;

import com.communal.model.cr.CRWater;

/**
 * 
 * @author Created by andrey.kuznetsov <br>
 * @author Last modified by $Author$ <br>
 * @author Last modified on $Date$ at revision $Revision$ <br>
 */
public class CRWaterForm extends CRForm{
	
	private final String TARIF_COLD_ID = "tarifColdId";
	private final String TARIF_HOT_ID = "tarifHotId";
	private final String CURRENT_VALUE_COLD = "currentValueCold";
	private final String CURRENT_VALUE_HOT = "currentValueHot";
	private final String PREVIOUS_VALUE_COLD = "previousValueCold";
	private final String PREVIOUS_VALUE_HOT = "previousValueHot";
	private final String SUMMA_COLD = "summaCold";
	private final String SUMMA_HOT = "summaHot";
	
	private Integer tarifColdId;
	private Integer tarifHotId;
	private Short currentValueCold;
	private Short currentValueHot;
	private Short previousValueCold;
	private Short previousValueHot;
	private Double summaCold;
	private Double summaHot;

	/**
	 * Constructor from JSON data for {@link CRWaterForm} <br>
	 * @param p_data - JSON data
	 */
	public CRWaterForm(Object p_data) {
		super( p_data, true );
		JSONObject jsonObject = JSONObject.fromObject(p_data);
		MorphDynaBean bean = (MorphDynaBean) JSONObject.toBean(jsonObject);
		tarifColdId = (Integer) bean.get(TARIF_COLD_ID);
		tarifHotId = (Integer) bean.get(TARIF_HOT_ID);
		currentValueCold = Short.parseShort(bean.get(CURRENT_VALUE_COLD).toString());
		currentValueHot = Short.parseShort(bean.get(CURRENT_VALUE_HOT).toString());
		previousValueCold = Short.parseShort(bean.get(PREVIOUS_VALUE_COLD).toString());
		previousValueHot = Short.parseShort(bean.get(PREVIOUS_VALUE_HOT).toString());
		summaCold = Double.parseDouble(bean.get(SUMMA_COLD).toString());
		summaHot = Double.parseDouble(bean.get(SUMMA_HOT).toString());
	}
	
	/**
	 * Constructor for {@link CRWaterForm} from water entity <br>
	 * @param p_communalRecord {@link CRWater}
	 */
	public CRWaterForm(CRWater p_water, String p_monthYear) {
		super( p_water, p_monthYear );
		tarifColdId = p_water.getTarifWaterCold().getId();
		tarifHotId = p_water.getTarifWaterHot().getId();
		currentValueCold = p_water.getCurrentValueCold();
		currentValueHot = p_water.getCurrentValueHot();
		previousValueCold = p_water.getPreviousValueCold();
		previousValueHot = p_water.getPreviousValueHot();
		summaCold = p_water.getSummaCold();
		summaHot = p_water.getSummaHot();
	}

	/**
	 * Returns id of tarif on cold water <br>
	 * @return {@link Integer};
	 */
	public Integer getTarifColdId() {
		return tarifColdId;
	}

	/**
	 * Sets id of tarif on cold water <br>
	 * @param p_tarifColdId - {@link Integer};
	 */
	public void setTarifColdId(Integer p_tarifColdId) {
		tarifColdId = p_tarifColdId;
	}

	/**
	 * Returns id of tarif on hot water <br>
	 * @return {@link Integer};
	 */
	public Integer getTarifHotId() {
		return tarifHotId;
	}

	/**
	 * Sets id of tarif on hot water <br>
	 * @param p_tarifHotId - {@link Integer};
	 */
	public void setTarifHotId(Integer p_tarifHotId) {
		tarifHotId = p_tarifHotId;
	}

	/**
	 * Returns current value on counter for cold water <br>
	 * @return {@link Short};
	 */
	public Short getCurrentValueCold() {
		return currentValueCold;
	}

	/**
	 * Sets current value on counter for cold water <br>
	 * @param p_currentValueCold - {@link Short};
	 */
	public void setCurrentValueCold(Short p_currentValueCold) {
		currentValueCold = p_currentValueCold;
	}

	/**
	 * Returns current value on counter for hot water <br>
	 * @return {@link Short};
	 */
	public Short getCurrentValueHot() {
		return currentValueHot;
	}

	/**
	 * Sets current value on counter for hot water <br>
	 * @param p_currentValueHot - {@link Short};
	 */
	public void setCurrentValueHot(Short p_currentValueHot) {
		currentValueHot = p_currentValueHot;
	}

	/**
	 * Returns previous value on counter for cold water <br>
	 * @return {@link Short};
	 */
	public Short getPreviousValueCold() {
		return previousValueCold;
	}

	/**
	 * Sets previous value on counter for cold water <br>
	 * @param p_previousValueCold - {@link Short};
	 */
	public void setPreviousValueCold(Short p_previousValueCold) {
		previousValueCold = p_previousValueCold;
	}

	/**
	 * Returns previous value on counter for hot water <br>
	 * @return {@link Short};
	 */
	public Short getPreviousValueHot() {
		return previousValueHot;
	}

	/**
	 * Sets previous value on counter for hot water <br>
	 * @param p_previousValueHot - {@link Short};
	 */
	public void setPreviousValueHot(Short p_previousValueHot) {
		previousValueHot = p_previousValueHot;
	}

	/**
	 * Returns summa for payment for cold water <br>
	 * @return {@link Double};
	 */
	public Double getSummaCold() {
		return summaCold;
	}

	/**
	 * Sets summa for payment for cold water <br>
	 * @param p_summaCold - {@link Double};
	 */
	public void setSummaCold(Double p_summaCold) {
		summaCold = p_summaCold;
	}

	/**
	 * Returns summa for payment for hot water <br>
	 * @return {@link Double};
	 */
	public Double getSummaHot() {
		return summaHot;
	}

	/**
	 * Sets summa for payment for hot water <br>
	 * @param p_summaHot - {@link Double};
	 */
	public void setSummaHot(Double p_summaHot) {
		summaHot = p_summaHot;
	}
	
	
}
